
package guoan.web.webCustomer;

import guoan.core.dto.RestResponse;
import guoan.domain.AdvPay;
import guoan.service.AdvPayService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/webCustomer/advPay")
public class AdvPayController {
    protected final Logger log = LoggerFactory.getLogger(getClass());

    @Autowired
    private AdvPayService advPayService;

    /**
     * 跳转到不同的内容页面
     * 
     * @param type
     * @return
     */
    @RequestMapping(value = "index_{type}", method = RequestMethod.GET)
    public String index(@PathVariable("type") String type, Model model){
        AdvPay advPay = advPayService.findOne(type);
        model.addAttribute("advPay", advPay);
        return "/webCustomer/advPay/" + type + "/index";
    }

    /** 查看 */
    @RequestMapping(value = "index_{type}/save", method = RequestMethod.POST)
    @ResponseBody
    public RestResponse<Boolean> toUpdate(@PathVariable("type") String type,
            AdvPay advPay){
        advPay.setType(type);
        advPayService.save(advPay);
        return RestResponse.ok(true);
    }
}
